-
Notifications
You must be signed in to change notification settings - Fork 275
Sam/ramp constraints #5778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sam/ramp constraints #5778
Conversation
c937925
to
63411e6
Compare
6f5eed7
to
6c9b34c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One logic bug, but nice architecture.
src/plugins/ramps/rampConstraints.ts
Outdated
// Filter out credit for sell in US for Paybis | ||
if (params.rampPluginId === 'paybis' && params.direction === 'sell') { | ||
yield params.regionCode.countryCode === 'US' | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it would be clearer as:
const isUsCredit =
direction === 'sell' &&
regionCode.countryCode === 'US' &&
params.paymentType === 'credit'
yield !isUsCredit
Which by DeMorgan's law could also be written:
yield direction !== 'sell' ||
regionCode.countryCode !== 'US' ||
params.paymentType !== 'credit'
It's close to what you have, but with ||
instead of &&
. Still, I feel like this inverted version is harder to understand.
6c9b34c
to
39244b9
Compare
39244b9
to
59a12db
Compare
Require `wallet` and use `currencyInfo` to get the `pluginId`.
We're removing `iach` from ramp plugin implementation and deprecating the value for documentation purposes. We'll remove the value variant completely when it's no longer a dependency for legacy code.
We need generators to not early exit on constraints so they're all applied. This is nice so we don't need to couple our constraints to other constrains when adding/removing. The contract is that all the constraints will get equal chance of being applied.
The list of supported countries is copied from the `buyPluginList.json` file. Revolut is not supported for sell direction, so no need to get the country codes from `sellPluginList.json`.
This was missing from the paybisProvider implementation.
The list of supported countries is copied from the `buyPluginList.json` and `sellPluginList.json`.
This may be a temporary constraint, but Paybis does not support sell now.
59a12db
to
3c951df
Compare
await request.wallet?.getAddresses({ tokenId: null }) | ||
)?.[0]?.publicAddress | ||
await request.wallet.getAddresses({ tokenId: null }) | ||
)[0].publicAddress |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Optional Chaining Removal Causes Runtime Error
Removing optional chaining from the getAddresses()
result introduces a potential runtime error. If getAddresses()
returns an empty array, accessing [0].publicAddress
attempts to read publicAddress
from undefined
, causing a runtime error. The prior implementation safely returned undefined
in this scenario.
CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
noneRequirements
If you have made any visual changes to the GUI. Make sure you have:
Note
Adds a centralized constraint system for ramps, updates request/types to require wallet and use crypto asset structs, and updates providers to honor constraints with minor payment-type fixes.
rampConstraints.ts
andutils/constraintUtils.ts
withvalidateRampCheckSupportRequest
/validateRampQuoteRequest
for global, per-payment rules (ACH/Venmo region limits, Revolut/PayPal country lists, Paybis restrictions).rampPluginTypes.ts
:CryptoAsset
and use inRampCheckSupportRequest.cryptoAsset
.RampQuoteRequest.wallet
required; remove reliance onrequest.pluginId
for currency plugin id.request.wallet.currencyInfo.pluginId
; minor address access fixes.iach
withach
in allowed/payment maps; update method maps; apply constraint checks; remove US sell credit filter (handled by constraints).applepay
/googlepay
) and return multiple quotes; add constraint checks; importPlatform
.RampSelectOptionScene
: pass correct crypto plugin id fromwallet.currencyInfo.pluginId
; remove non-null wallet assertion in approve.fiatPluginTypes.ts
: deprecateiach
(useach
).Written by Cursor Bugbot for commit 3c951df. This will update automatically on new commits. Configure here.